<?php
	class_exists('D') || die('ok');

	require_once D_DIR. '/vendor/Excel/reader.php';

	$data = new Spreadsheet_Excel_Reader();
	$data->setOutputEncoding('utf-8');




	$return	= array('success'=>true);

	if ( strstr($_FILES['xsl']['name'], '.') != '.xls' ){
		$return['success']	= false;
		$return['msg']		= "文件格式错误!";
		echo json_encode($return);
		die;
	}

	if ( $_FILES['xsl']['size'] > 1024 * 100 ){
		$return['success']	= false;
		$return['msg']		= "文件尺寸太大!";
		echo json_encode($return);
		die;
	}


	try{
		$data->read($_FILES['xsl']['tmp_name']);
	}catch(Exception $e){
		$return['success']	= false;
		$return['msg']		= "文件无法识别!";
		echo json_encode($return);
		die;		
	}


	$rows	= $data->sheets[0]['numRows'];
	$cols	= $data->sheets[0]['numCols'];
	$cells	=& $data->sheets[0]['cells'];

	//file_put_contents('log.txt', '<?'.'php return '.var_export($cells ,1).'?'.'>');

	$stuff	= new stuff($cells, $db);

	echo json_encode($return);
	die;

?>